package org.grayrabbit.cms.content.exp;

import java.util.List;

import org.grayrabbit.cms.content.base.AbstractExportMission;
import org.grayrabbit.cms.content.base.BaseMission;
import org.grayrabbit.cms.content.base.CountDto;
import org.grayrabbit.cms.entity.Content;


/**
 *		XMLExport.java
 *		@Author      hasau   
 *		@CreateTime  2012-2-8  上午9:27:20	
 **/
public class XMLExportMission extends AbstractExportMission{

	private List<Content> list;
	private String parentName;
	private String key;
	public XMLExportMission(List<Content> list,String parentName,String key) {
		this.list = list;
		this.parentName = parentName;
		this.key = key;
	}



	@Override
	public void exportContents() {
		CountDto dto = (CountDto)(BaseMission.getMapItem(key));
		dto.setMissionLeftNum(list.size());
		BaseMission.addMapItem(key,dto);		 
		for(Content c : list){
			while(true){ 
				if(dto.getThreadCurrentNum()< BaseMission.THREAD_MAX_NUM+1){ 
					XMLExportThread  xmlExportThread = new XMLExportThread(c,parentName,key);
					Thread t= new Thread(xmlExportThread);
					t.start();					
					break;
				} 
			} 
		}		
	}
 

}
